<%@ page import="MypageController.MyWrite.MyWriteBean" %>
<%@ page import="MypageController.MyMain.MyMainBean" %>
<%@ page import="MypageController.MyComment.MyCommentBean" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String id = (String)request.getAttribute("id");
int mypageid = (Integer)request.getAttribute("mypageid");
int number = (Integer)request.getAttribute("number");
int numbermax = (Integer)request.getAttribute("numbermax");
int level = (Integer)request.getAttribute("level");
MyCommentBean commentlist[] = (MyCommentBean[])request.getAttribute("commentlist");	
MyWriteBean entries[] = (MyWriteBean[])request.getAttribute("entries");
MyMainBean mypagedata = (MyMainBean)request.getAttribute("mypagedata");


int i = 0;
if(number <= 0){
	 i = 0;
}else{ 
	i = 1;
}
int pageAll = 1;
String color;
if(level == 1){
	color = "#60b615";
}else{
	color = "#0f89d2";
}
System.out.println("숫자는 = " + i + " || 글 길이 = " + entries.length +" || 총 길이 = " + numbermax);
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="/KOMORIUTA/Mypage/Css/MpBord.css"> 

<script src="/KOMORIUTA/Mypage/Mp_Script.js" type="text/JavaScript"></script>
<script src="/KOMORIUTA/Mypage/jquery.js" type="text/JavaScript"></script>
</head>
<body>
<form id="modify"  method="post" action="/KOMORIUTA/MyWriteServ.do">
<input type="hidden" name="action" value="modify">
<input type="hidden" name="id" value="<%=id%>">
<input type="hidden" name="mypageid" value="<%=mypageid%>">
<input type="hidden" name="entriid" value="<%=entries[i].getID()%>">
<input type="hidden" id="currentPage" name="currentPage" value = "<%=pageAll%>"/>

<table align="center" width="696" height="100%" cellpadding="0" cellspacing="0">
	<tr>
		<td align="center" width="100%" height="100" background="<%=request.getContextPath() %>/Mypage/image/topskin.jpg" style="border-right: 2px solid <%=color %>; border-bottom: 2px solid <%=color %>">
			<table width="100%"cellpadding="0" cellspacing="0">
				<tr height="20%"><td>&nbsp;</td></tr>
				
				<tr align="center">
					<td width="80%">
						<h1><%=mypagedata.getBlog_Tilte()%></h1>
					</td>
				</tr>
				
				<tr>
					<td align="right" valign="bottom" >
						<%=mypagedata.getBlog_Intro() %>
					</td>
				</tr>
			</table>
			
			
		</td>
	</tr>
	
	<tr>
		<td align="right" valign="middle">
			<a href=javascript:startPage("<%=id%>","<%=0%>")>
			
			
				<!-- 
				<% if(level == 1){ %>共有者
				<% }else{ %>製作者<% }%>[<%=id%>]
				 -->
			
			
				<img alt="" src="<%=request.getContextPath() %>/Main/image/Blog_My.png">
			</a>　
			<a href=javascript:entriWrite('<%=id%>',<%=mypageid%>)> 
				<img alt="" src="<%=request.getContextPath() %>/Main/image/Blog_Wr.png">
			</a>　
				<% if(level == 2){ %>
			<a href=javascript:manage('<%=id%>',<%=mypageid%>)>
				<img alt="" src="<%=request.getContextPath() %>/Main/image/Blog_Ad.png">
			</a>
				<% } %>&nbsp;&nbsp;
			<% if(entries[i].getEnt_Nick().equals(id)){ %>
			<a href=javascript:entriModify("<%=id%>","<%=entries[i].getID() %>","<%=mypageid%>")>
				<img alt="" src="<%=request.getContextPath() %>/Main/image/Blog_Re.png">
			</a>&nbsp;&nbsp;
			<a href=javascript:entriDelet("<%=id%>","<%=entries[i].getID() %>","<%=mypageid%>")>
				<img alt="" src="<%=request.getContextPath() %>/Main/image/Blog_Dl.png">
			</a>
			<% } %>
		</td>
	</tr>
	
	<tr>
		<td style="border-bottom: 2px solid <%=color %>">
			<table cellpadding="0" cellspacing="0">
				<tr>
					<td>
						<h2><%=entries[i].getEnt_Title()%></h2>
					</td>
					<td width="20"></td>
					<td>
						<h5><a href=javascript:kategoriDate("<%=id%>","<%=mypageid%>","<%=entries[i].getEnt_Date()%>")><%=entries[i].getEnt_DateString()%></a></h5>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	
	<tr>
		<td width="696"><br/>
			<%=entries[i].getEnt_Contents() %>
		</td>
	</tr>
	
	<tr>
		<td align="right" style="border-bottom: 1px solid <%=color %>">
			by <%if(entries[i].getEnt_Nick().equals(id)){%><%=entries[i].getEnt_Nick() %><%}else{%><a href=javascript:WriteGo("<%=id%>","<%=entries[i].getEnt_Nick()%>") class="black"><%=entries[i].getEnt_Nick()%></a><%}%>
			덧글<label class="<%=entries[i].getID()%>">(<%=entries[i].getEnt_ComCount()%>)</label>
		</td>
	</tr>
	

	<tr>
		<td style="border-bottom : 1px solid <%=color %>">
			<div id="fild<%=entries[i].getID()%>">
			<%for(int j = 0; j < commentlist.length; j++){ %>
			<div class="commlist<%=commentlist[j].getEntries_Id() %>">
			<p id="comid<%=commentlist[j].getID()%>" class="commlist" >
			by <% if(commentlist[j].getCblog_Nick().equals(id)){ %><label class="comtitle"><%=commentlist[j].getCblog_Nick() %></label><% }else{ %><a href=javascript:WriteGo("<%=id %>","<%=commentlist[j].getCblog_Nick()%>")><label class="comtitle"><%=commentlist[j].getCblog_Nick()%></label></a><% } %>
			<label class="comdate" ><%=commentlist[j].getCblog_Date() %></label>
			<% if(commentlist[j].getCblog_Nick().equals(id)){ %>
			<a href=javascript:commentDelet("<%=commentlist[j].getID()%>","<%=commentlist[j].getEntries_Id()%>") >
				<img alt="" src="<%=request.getContextPath() %>/Main/image/Blog_Dl.png">
			</a><% } %><br /><br />
			<%=commentlist[j].getCblog_Contents()%><br />
			</p></div>
		<% } %>
		</td>
	</tr>
	
	<tr>
		<td align="center" style="border-bottom: 2px solid <%=color %>">
			<table>
				<tr>
					<td>
						<input class="nick" type="hidden" readonly="readonly" value="<%=id%>">
						<span id="check<%=entries[i].getID()%>" class="warning"><img src="/KOMORIUTA/Mypage/image/erro.png" width="20" height="20" />内容を書いて下さい。</span><br />
						<textarea class="textarea<%=entries[i].getID()%>" style="height:100px; width:500px; border: 1px solid <%=color %>"></textarea>
					</td>
					<td>
						<label class="comwrith">
						<input type="button" class="btn_text1" onclick="commentWrite(<%=mypageid%>, <%=entries[i].getID()%>)" >
						</label>
					</td>
				</tr>
				<tr>
					<td align="center">
						
					</td>
				</tr>
			</table>
			
			
			
		</td>
	</tr>
	
	<tr>
		<td valign="middle">
			<%if(numbermax != 0){
		if(number == 0){%>
			<a href=javascript:page("<%=id%>","<%=number+1%>","<%=entries[i+1].getID()%>") class="black"><img alt="" src="<%=request.getContextPath() %>/Main/image/down.png"><%=entries[i+1].getEnt_Title()%></a>
		<%}else if(number == numbermax){%>
			<a href=javascript:page("<%=id%>","<%=number-1%>","<%=entries[i-1].getID()%>") class="black"><img alt="" src="<%=request.getContextPath() %>/Main/image/up.png"><%=entries[i-1].getEnt_Title()%></a>
		<%}else{%>
			<a href=javascript:page("<%=id%>","<%=number-1%>","<%=entries[i-1].getID()%>") class="black"><img alt="" src="<%=request.getContextPath() %>/Main/image/up.png"><%=entries[i-1].getEnt_Title()%></a><br/>
			<a href=javascript:page("<%=id%>","<%=number+1%>","<%=entries[i+1].getID()%>") class="black"><img alt="" src="<%=request.getContextPath() %>/Main/image/down.png"><%=entries[i+1].getEnt_Title()%></a>
		<%}
	}%>
		</td>
	</tr>
</table>


	
	

</form>
</body>
</html>